library(tidyverse)
library(dplyr)
library(stringr)
library(janitor)
library(here)
# Load data from first csv file
halloween_candies <-
read_csv(here("clean_data/halloween_candies.csv"))
1.4.2 Analysis questions
Q1
# What is the total number of candy ratings given across the three years
halloween_candies %>%
group_by(ratings)%>%
drop_na(ratings)%>%
summarise(candy_ratings = n()) %>%
summarise(total_ratings = sum(candy_ratings))
NA
NA
Q2
# What was the average age of people who are going out trick or treating and the average age of people 3. not going trick or treating?
halloween_candies %>%
group_by(going_out) %>%
summarise(avg_age = mean(age, na.rm = TRUE))
NA
NA
NA
Q3
# For each of joy, despair and meh, which candy bar revived the most of these ratings?
halloween_candies %>%
drop_na(ratings) %>%
group_by(candies, ratings) %>%
summarise(candy_ratings = n()) %>%
filter(candy_ratings == max(candy_ratings))
NA
NA
NA
Q4
# How many people rated Starburst as despair
halloween_candies %>%
filter(candies == 'starburst') %>%
group_by(candies, ratings) %>%
drop_na(ratings) %>%
summarise(starburst_ratings = n()) %>%
filter(ratings == 'despair')
NA
NA
NA
Q5
# What was the most popular candy bar by this rating system for each gender in the dataset?
halloween_candies %>%
filter(gender == c('male', 'female')) %>%
group_by(candies, gender) %>%
drop_na(ratings) %>%
summarise(popular_ratings = sum())
NA